package com.chapter01exercise.homework10;

/**
 * @Author 小闽
 * @Date 2024/8/17 20:14
 * @PackageName: com.chapter01exercise.homework10
 * @ClassName: Doctor
 * @Description: 父类
 * @Version 1.0
 */
public class Doctor {
    private String name;
    private int age;
    private String job;
    private char gender;
    private double sal;

    /**
     * 构造器
     * @param name
     * @param age
     * @param job
     * @param gender
     * @param sal
     */
    public Doctor(String name, int age, String job, char gender, double sal) {
        this.name = name;
        this.age = age;
        this.job = job;
        this.gender = gender;
        this.sal = sal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }
    /**
     * 重写父类的equals()方法
     */
    public boolean equals(Object object){
        // 比较两个对象是否相等
        if (this == object){
            return true;
        }
        // 判断obj对象是否是Doctor或者其子类
        if (!(object instanceof Doctor)){
            return false;
        }
        Doctor doctor = (Doctor)object;
        return  this.name.equals(doctor.name) && this.age == doctor.age
                && this.job.equals(doctor.job) && this.gender == doctor.gender
                && this.sal == doctor.sal;
    }
}
